<template>
  <div class="nav">
    <el-menu
      background-color="#32415780"
      text-color="#FFFFFF"
      :default-active="this.$route.path"
      class="sidebar-el-menu"
      :collapse="collapse"
      router
      unique-opened
    >
      <el-submenu index="1">
        <template slot="title"
          ><i class="el-icon-upload"></i><span>图片管理</span></template
        >
        <el-menu-item-group>
          <el-menu-item index="/index">中心</el-menu-item>
        </el-menu-item-group>
        <!--<el-menu-item-group>-->
          <!--<el-menu-item index="login">登录</el-menu-item>-->
        <!--</el-menu-item-group>-->
        <el-menu-item-group>
          <el-menu-item index="/index/photoManage">管理图片</el-menu-item>
        </el-menu-item-group>
        <el-menu-item-group>
          <el-menu-item index="/index/TagManage">分类管理</el-menu-item>
        </el-menu-item-group>
        <el-menu-item-group>
          <el-menu-item index="/index/collection">收藏管理</el-menu-item>
        </el-menu-item-group>
      </el-submenu>
    </el-menu>
  </div>
</template>
<script>
import bus from "../../plugins/bus.js";
export default {
  data() {
    return {
      collapse: true,
      navMenu: [],
    };
  },
  created() {
    // 通过 Event Bus 进行组件间通信，来折叠侧边栏
    bus.$on("collapse", (msg) => {
      this.collapse = msg;
    });
    /*     //发送ajax获取菜单信息
      this.req
        .get("/account/role")
        .then(response => {
          //将接受到的导航数据赋值给navMenu
          this.navMenu = response.data;
        })
        .catch(err => {
          console.log(err);
        }); */
  },
};
</script>
<style lang="less">
.nav {
  .sidebar-el-menu {
    height: 100%;
    border: none;
    .el-menu-item {
      background-color: transparent !important;
    }
    .el-menu-item:hover {
      background-color: #324157 !important;
    }
    .el-submenu {
      .el-submenu__title,
      .el-menu {
        background-color: transparent !important;
        .el-menu-item {
          background-color: transparent !important;
        }
      }
      .el-submenu__title:hover,
      .el-menu .el-menu-item:hover {
        background-color: #324157 !important;
      }
    }
  }
  .sidebar-el-menu:not(.el-menu--collapse) {
    width: 200px;
  }
}
.el-menu--vertical {
  .el-menu--popup {
    padding: 0;
    .el-menu-item {
      background-color: transparent !important;
    }
  }
}
.el-menu--vertical {
  .el-menu--popup {
    .el-menu-item:hover {
      background-color: #324157 !important;
    }
  }
}
</style>
